1 <?php
2 session_start();
3 if(isset($_SESSION['user']))
4 {
5
6 }
7 else{
8 echo"<script>location.href='login.html'</script>";
9 }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14 <title>Customer </title>
15 <style>
16 body {
17 margin: 0;
18 font-family: Arial, Helvetica, sans-serif;
19 background: #484848;
20 }
21 .topnav {
22 overflow: hidden;
23 background-color:#8d2663;
24 height: 70px;
25 border: 3px solid #b40a70;
26 }
27
28 .topnav a {
29 float: left;
30 color: #f2f2f2;
31 text-align: center;
32 padding: 14px 16px;
33 text-decoration: none;
34 font-size: 35px;
35 font-weight: bold;
36 }
37
38 .topnav-right {
39 float: right;
40 }
41
42
43 fieldset {
44 background: #FAFAFA;
45 padding: 10px;
46 margin:auto;
47 max-width:450px;
48 box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
49 border-radius: 10px;
50 border: 6px solid #b40a70;
51
52
53 }
54
55 </style>
56 </head>
57 <body>
58 <div class="topnav">
59 <a class="active" href="home.html"><img src="ic_add_pet.png"></a>
60 <a href="customer.php">Customers</a>
61 <div class="topnav-right">
62 <a href="logout.php">logout</a>
63 </div>
64 </div>
65 <form>
66 <button type="submit" formaction="customer.php" style="margin:15px;height: 30px;width: 100px;
67 border-radius:15px;
68 border: 3px solid #b40a70;background-color: #8d2663;color:#f2f2f2;font-size:15px;cursor:pointer;">back</button>
69 </form>
70 <form method="post" action="customerupdate.php">
71 <fieldset>
72 <input type="text" name="id" placeholder="Enter the customer id" style="width:100%;height:30px;
73 border: 2px solid #b40a70; border-radius:5px; background:transparent;" required>
74 <br><br>
75 <input type="text" name="fname" placeholder="Enter customer first_name" style="width:100%;height:30px;
76 border: 2px solid #b40a70; border-radius:5px; background:transparent;" required>
77 <br><br>
78 <input type="text" name="minit" placeholder="Enter customer middle_name" style="width:100%;height:30px;
79 border: 2px solid #b40a70; border-radius:5px; background:transparent;" required>
80 <br><br>
81 <input type="text" name="lname" placeholder="Enter customer last_name" style="width:100%;height:30px;
82 border: 2px solid #b40a70; border-radius:5px; background:transparent;" required>
83 <br><br>
84 <input type="text" name="address" placeholder="Enter customer address" style="width:100%;height:30px;
85 border: 2px solid #b40a70; border-radius:5px; background:transparent;" required>
86 <br><br>
87 <input type="submit" name="submit" value="update" style="width:100%;height:30px;
88 border: 2px solid #b40a70; border-radius:5px; cursor:pointer;background-color: #8d2663">
89 </fieldset>
90 </form>
91 </body>
92 </html>
93 <?php
94 if(isset($_POST["submit"]))
95 {
96 // define variables and set to empty values
97 $servername = "localhost";
98 $username = "root";
99 $password = "";
100 $dbname = "Petshop_management";
101
102 // Create connection
103 $conn = new mysqli($servername, $username, $password, $dbname);
104 // Check connection
105 if ($conn->connect_error) {
106 die("Connection failed: " . $conn->connect_error);
107 }
108 //echo " CONNECTION ESTABLISHED \r\n";
109 //echo " INSERTION IN PROCESS";
110 $id = $_POST["id"];
111 $fname = $_POST["fname"];
112 $minit= $_POST["minit"];
113 $lname = $_POST["lname"];
114 $address = $_POST["address"];
115
116
117 $Query2="select count(*) from customer where cs_id='$id'";
118 $Execute = mysqli_query($conn,$Query2);
119 $count = mysqli_fetch_row($Execute);
120 if($count[0]==1)
121 {
122 $sql = "UPDATE customer set cs_fname='$fname',cs_minit='$minit' ,cs_lname='$lname' ,cs_address='$address'
123 where cs_id='$id'";
124 if ($conn->query($sql) == TRUE) {
125 echo'<div>
126 <h1 style="color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">'
127 .$id. ' updated successfully</h1>
128 </div>';
129 } else {
130 echo "Error: " . $sql . "<br>" . $conn->error;
131 }
132
133 }
134 else{
135 echo '<div>
136 <h1 style="color:#f2f2f2;font-size:30px; font-family: "Roboto", sans-serif;margin:auto;">Given cs_id not found</h1>
137 </div>';
138 }
139
140
141 $conn->close();
142 }
143 ?>